package cn.iocoder.yudao.module.famous.doctor.dal.mysql.videohistory;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.inquiry.InquiryDO;
import cn.iocoder.yudao.module.famous.doctor.dal.dataobject.videohistory.VideoHistoryDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.famous.doctor.controller.admin.videohistory.vo.*;
import org.apache.ibatis.annotations.Param;

import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

/**
 * 我的视频记录 Mapper
 *
 * @author Test1
 */
@Mapper
public interface VideoHistoryMapper extends BaseMapperX<VideoHistoryDO> {

    default PageResult<VideoHistoryDO> selectPage(VideoHistoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<VideoHistoryDO>()
                .eqIfPresent(VideoHistoryDO::getVideoId, reqVO.getVideoId())
                .betweenIfPresent(VideoHistoryDO::getCreateTime, reqVO.getCreateTime())
                .eq(VideoHistoryDO::getCreator, getLoginUserId())
                .orderByDesc(VideoHistoryDO::getCreateTime));
    }

    default List<VideoHistoryDO> selectList(VideoHistoryExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<VideoHistoryDO>()
                .eqIfPresent(VideoHistoryDO::getVideoId, reqVO.getVideoId())
                .betweenIfPresent(VideoHistoryDO::getCreateTime, reqVO.getCreateTime())
                .eq(VideoHistoryDO::getCreator, getLoginUserId())
                .orderByDesc(VideoHistoryDO::getId));
    }

    IPage<VideoMyHistoryRespVO> getMessage(Page<?> page, @Param("loginUserId") Long loginUserId);
}
